package com.hut.blog.service;

import com.hut.blog.mapper.BlogMapper;
import com.hut.blog.mapper.UserMapper;
import com.hut.blog.model.BlogInfo;
import com.hut.blog.model.Result;
import com.hut.blog.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogMapper blogMapper;

    /**
     * 获取blog列表
     * @return
     */
    public List<BlogInfo> getList() {
        return blogMapper.getBlogList();
    }

    /**
     * 获取blog详情页
     * @param id
     * @return
     */
    public BlogInfo getBlogDetail(Integer id) {
        return blogMapper.getBlogInfoById(id);
    }
    public boolean addBlog(BlogInfo blogInfo) {
        Integer line = blogMapper.insertBlogInfo(blogInfo);
        if(line >0) {
            return true;
        }
        return false;
    }

    public Integer update(BlogInfo blogInfo) {
        return blogMapper.updateBlogInfo(blogInfo);
    }
}
